package com.longxi.tianjintianbao.ui.presenter.quality;

import com.longxi.tianjintianbao.R;
import com.longxi.tianjintianbao.ui.adapter.QualityListPagerAdapter;
import com.longxi.tianjintianbao.ui.base.BaseActivity;
import com.longxi.tianjintianbao.ui.base.BasePresenter;
import com.longxi.tianjintianbao.ui.fragment.repair.RepairListFragment;
import com.longxi.tianjintianbao.ui.view.quality.IQualityListAtView;
import com.longxi.tianjintianbao.utils.MyUtils;

import java.util.ArrayList;
import java.util.List;

public class QualityListAtPresenter extends BasePresenter<IQualityListAtView> {

    private QualityListPagerAdapter qualityListPagerAdapter;

    private void initVariable() {
        mCategoryList = new ArrayList<>();
        mCategoryList.add("未检查完");
        mCategoryList.add("已检查完");
    }

    //tab 标签页
    private List<String> mCategoryList;

    public List<String> getCategoryList() {
        if (mCategoryList == null) {
            mCategoryList = new ArrayList<>();
        }
        return mCategoryList;
    }

    public QualityListAtPresenter(BaseActivity context) {
        super(context);
    }

    public void setBar() {
        mContext.setTitle("工作检查");
        mContext.setTvLeft(MyUtils.getString(R.string.home));
        initVariable();
    }

    public void initViewPager(){
        qualityListPagerAdapter = new QualityListPagerAdapter(mContext.getSupportFragmentManager(), getCategoryList());
        getView().getViewPager().setAdapter(qualityListPagerAdapter);
        getView().getViewPager().setOffscreenPageLimit(getCategoryList().size() - 1);
        getView().getTabLayout().setTabSpaceEqual(true);
        getView().getTabLayout().setViewPager(getView().getViewPager());
    }

    @Override
    public void detachView() {
        super.detachView();
        this.qualityListPagerAdapter = null;
        this.mCategoryList = null;
    }
}
